import { createStore } from 'vuex'

export default createStore({
  state: {
    list: JSON.parse(localStorage.getItem('list'))|| []
  },
  getters: {
  },
  mutations: {
    addList(state, obj) {
      state.list.push({
        ...obj,
        id: new Date().getTime(),
        status: false,
        name:obj
      })
      localStorage.setItem('list',JSON.stringify(state.list))
    },
    editStatus(state) {
      state.list.status = !state.list.status
    },
    del(state, id) {
      let index = state.list.findIndex((item) => item.id == id)
      state.list.splice(index, 1)
      localStorage.setItem('list',JSON.stringify(state.list))
    }
  },
  actions: {
  },
  modules: {
  }
})
